package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbTypeTemplateMapper;
import com.dongdongshop.operator.pojo.TbTypeTemplate;
import com.dongdongshop.operator.service.TypeTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Component
public class TypeTemplateServiceImpl implements TypeTemplateService {

    @Autowired
    private TbTypeTemplateMapper typeTemplateMapper;

    @Override
    public List<TbTypeTemplate> getTypeTemplate(String name) {
        List<TbTypeTemplate> tbTypeTemplates = typeTemplateMapper.getTypeTemplate(name);
        return tbTypeTemplates;
    }

    @Override
    @Transactional
    public void addTypeTemplate(TbTypeTemplate typeTemplate) {
        typeTemplateMapper.insertSelective(typeTemplate);
    }

    @Override
    public TbTypeTemplate getTypeTemplateById(Long id) {
        TbTypeTemplate typeTemplate = typeTemplateMapper.selectByPrimaryKey(id);
        return typeTemplate;
    }

    @Override
    @Transactional
    public void updateTypeTemplate(TbTypeTemplate typeTemplate) {
        typeTemplateMapper.updateByPrimaryKey(typeTemplate);
    }

    @Override
    @Transactional
    public void deleteTypeTemplateByIds(Long[] ids) {
        typeTemplateMapper.deleteTypeTemplateByIds(ids);
    }
}
